package main

import (
	"fmt"
	"github.com/ecodeclub/ekit/slice"
)

//func main() {
//	server := gin.Default()
//	server.GET("/hello", func(context *gin.Context) {
//		context.String(http.StatusOK, "hello world")
//	})
//	server.Run(":8080")
//}

func main() {
	sliceStr := []string{"13285471922", "123456"}
	str1 := slice.Map[string, string](sliceStr, func(idx int, src string) string {
		return src
	})
	fmt.Println(str1)
	//
	//// dsn := "root:root@tcp(webook-mysql:11309)/webook?charset=utf8mb4&parseTime=True&loc=Local"
	//db, err := gorm.Open(mysql.Open(config.Config.DB.DSN))
	//if err != nil {
	//	panic(err)
	//}
	//errInit := dao.InitTable(db)
	//if errInit != nil {
	//	panic(errInit)
	//}
	//
	//ud := dao.NewUserDao(db)
	//repo := repository.NewUserRepository(ud)
	//svc := service.NewUserService(repo)
	//u := web.NewUserHandler(svc)
	//
	//server := gin.Default()
	//configs := cors.Config{
	//	//AllowOrigins: []string{"http://localhost:3000"},
	//	//AllowMethods: []string{"GET", "POST", "PUT", "DELETE"},
	//	AllowHeaders: []string{"Origin", "Content-Type", "Authorization"},
	//	// 允许暴露的header
	//	ExposeHeaders: []string{"x-jwt-token"},
	//
	//	// 是否允许携带cookies之类的东西
	//	AllowCredentials: true,
	//	MaxAge:           12 * time.Hour,
	//	//用于 动态判断哪些请求来源（origin）被允许访问资源。
	//	AllowOriginFunc: func(origin string) bool {
	//		if strings.HasPrefix(origin, "http://localhost") {
	//			return true // 允许所有 localhost 来源的请求
	//		}
	//		return strings.Contains(origin, "my.com") // 只允许包含 "my.com" 的来源
	//	},
	//}
	//server.Use(cors.New(configs))
	//
	//redisClient := redis.NewClient(&redis.Options{
	//	Addr: config.Config.Redis.Addr,
	//})
	//limiter := ratelimit.NewRedisSlidingWindowLimiter(redisClient, 1*time.Second, 10)
	//server.Use(ratelimit.NewBuilder(limiter).Build())
	//
	//// 创建一个基于Cookie的session存储
	////store := cookie.NewStore([]byte("secret"))
	////store, err := redis.NewStore(16, "tcp", "localhost:6379", "", "", []byte("secret"), []byte("dkfjgkdf"))
	////if err != nil {
	////	panic(err)
	////}
	////server.Use(sessions.Sessions("mysession", store))
	////server.Use(middleware.NewLoginMiddlewareBuilder().
	////	IgnorePaths("/users/login").
	////	IgnorePaths("/users/signup").
	////	IgnorePaths("/users/loginJwt").
	////	Build())
	//server.Use(middleware.NewLoginJwtMiddlewareBuilder().
	//	IgnorePaths("/users/loginJwt").
	//	IgnorePaths("/users/login").
	//	IgnorePaths("/users/signup").
	//	Build())
	//u.RegisterRoutes(server)
	//
	//server.Run(":8080")
}
